package java111;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Day12 {
    // https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&ru=/exam/oj
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        if (pHead1 == null || pHead2 == null) {
            return null;
        }
        ListNode cur1 = pHead1;
        ListNode cur2 = pHead2;
        int count1 = 0, count2 = 0;
        while (cur1 != null) {
            count1++;
            cur1 = cur1.next;
        }
        while (cur2 != null) {
            count2++;
            cur2 = cur2.next;
        }
        int differ = count1 - count2;
        cur1 = pHead1;
        cur2 = pHead2;
        if (differ < 0) { // 说明count1短
            differ = -differ;
            while (differ-- > 0) {
                cur2 = cur2.next;
            }
        } else {
            while (differ-- > 0) {
                cur1 = cur1.next;
            }
        }
        while (cur1 != cur2) {
            cur1 = cur1.next;
            cur2 = cur2.next;
        }
        return cur2;
    }

    // https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId=182&tqId=34789&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            Set<Character> set = new HashSet<>();
            for(int i = 0; i < str2.length(); i++){
                set.add(str2.charAt(i));
            }
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < str1.length(); i++){
                char ch = str1.charAt(i);
                if(!set.contains(ch)){
                    sb.append(ch);
                }
            }
            System.out.println(sb);
        }
    }

    //https://ac.nowcoder.com/acm/problem/26226
    public static void main2(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String str = in.next();
        long[] s = new long[n]; // s[i]表示字符串str中[0,i]区间内，有多少个 's'
        long[] h = new long[n]; // h[i]表示字符串str中[0,i]区间内，有多少个 'sh'
        long[] y = new long[n]; // y[i]表示字符串str中[0,i]区间内，有多少个 'shy'
        s[0] = str.charAt(0) == 's' ? 1 : 0;
        for(int i = 1; i < n; i++){
            char ch = str.charAt(i);
            if(ch == 's'){
                s[i] = s[i-1] + 1;
                h[i] = h[i-1];
                y[i] = y[i-1];
            } else if(ch == 'h'){
                s[i] = s[i-1];
                h[i] = h[i-1] + s[i-1];
                y[i] = y[i-1];
            } else if(ch == 'y'){
                s[i] = s[i-1];
                h[i] = h[i-1];
                y[i] = y[i-1] + h[i-1];
            } else {
                s[i] = s[i-1];
                h[i] = h[i-1];
                y[i] = y[i-1];
            }
        }
        System.out.println(y[n-1]);
    }
}


